home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
graphics
/
shadow20.arj
/
SHADOWBX.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-12-10
|
7KB
|
299 lines
'******************************SHADOW2.BAS*******************************
'
'Wow!! You guys, what complainers! First I give you a real true-blue
'shadow box and now you complain that you have to exit the program each
'time, "why can't I see other backgrounds with the shadow," "Why did you
'print the character, you didn't need to do that" et cetera, et cetera
'and more et ceteras.
'
'So, this is SHADOW2.BAS and answers -most- of the complaints.
'12/9/93
'
'Oh...oh... almost forgot; now there are lots more SUBs and FUNCTIONS
'as I was reading Ethan Winer's book "BASIC Techniques and Utilities,"
'PC Magazine Ziff-Davis Press; 1991 and used several (many?) of
'Ethan's ideas on LOCATE and COLOR.
'===================================================================
'PREAMBLE to original (not so brilliant) SHADOWBX.BAS follows...
'
'JRD NOTE: This works.
'Can now make a real shadowed box as the characters in the shadow
'are reprinted to the screen in the shaded color
'coooool
'12/6/93
'
'The box shape
' █▀▀▀▀▀▀█
' █ █
' █▄▄▄▄▄▄█
'
'
'declarations, SUBs and FUNCTIONS
CONST False = 0, True = NOT False
DECLARE FUNCTION IntPeek% (Address%)
DECLARE FUNCTION ReturnKey$ ()
DECLARE SUB CursorOn ()
DECLARE SUB CursorOff ()
DECLARE SUB Pause (Seconds%)
DECLARE SUB WaitKey ()
DECLARE SUB LocateIt (Row%, text$)
DECLARE SUB ColorIt (Fgd%, Bkgd%)
DECLARE SUB Mono (Flag%)
DECLARE SUB Shadowbox (top%, Bottom%, Wide%, BoxColr%, Fgd%, Bkgd%)
DECLARE SUB PokeColor (Address%, Colr%)
DECLARE SUB IntPoke (Address%, Value%)
'executable code starts here
DEF FNCenterit% (text$) = 41 - (LEN(text$) \ 2)
DEFINT A-Z
SCREEN 0
WIDTH 80
COLOR 15, 1
CLS
CALL Mono(Flag%)
'Flag% = True
IF Flag% THEN
CALL ColorIt(0, 7)
CLS
text$ = "Oops.... Can't run this with a monochrome monitor"
CALL LocateIt(10, text$)
text$ = "Because all I can test is COLOR. Sorry... Press <Esc> to END"
CALL LocateIt(12, text$)
text$ = " "
CursorOn
CALL LocateIt(14, text$)
IF ReturnKey$ = CHR$(27) THEN
CursorOff
END
END IF
END IF
count = 1
DEF SEG = &HB800 'got to have this or big crash!
Again:
CALL ColorIt(15, 1)
CLS
'STOP
SELECT CASE count
CASE 1
Char% = 96
FOR X% = 1 TO 24
PRINT STRING$(80, X% + Char%);
NEXT
CASE 2
Char% = 64
FOR X% = 1 TO 24
PRINT STRING$(80, X% + Char%);
NEXT
CASE 3 TO 21
Char% = 173 + count
FOR X% = 1 TO 24
PRINT STRING$(80, Char%);
NEXT
CASE 22
count = 1
GOTO Again
CASE ELSE
PRINT "We got a BIG ERROR!!!"
BEEP
END
END SELECT
text$ = " Enter box Size and color with commas between the numbers "
CALL ColorIt(11, 0)
CALL LocateIt(1, text$)
text$ = " top%, Bottom%, Wide%, boxcolr%, fgd%, bkgd% "
CALL ColorIt(15, 4)
CALL LocateIt(2, text$)
text$ = SPACE$(18)
CALL ColorIt(7, 0)
CALL LocateIt(3, text$)
LOCATE 3, FNCenterit%(text$)
CursorOn
INPUT "", top%, Bottom%, Wide%, BoxColr%, Fgd%, Bkgd%
CursorOff
CALL Shadowbox(top%, Bottom%, Wide%, BoxColr%, Fgd%, Bkgd%)
CALL Pause(5)
text$ = " PRESS 'Y' to try another BACKGROUND and box dimensions..."
CALL ColorIt(15, 0)
CALL LocateIt(12, text$)
text$ = " "
CursorOn
CALL LocateIt(14, text$)
LOCATE 14, FNCenterit(text$)
IF UCASE$(ReturnKey$) = "Y" THEN
count = count + 1
GOTO Again
ELSE
CursorOff
top% = 14: Bottom% = 22: Wide% = 44: BoxColr% = 4: Fgd% = 15: Bkdg% = 2
CALL Shadowbox(top%, Bottom%, Wide%, BoxColr%, Fgd%, Bkgd%)
text$ = "Hope you liked this little demo..."
CALL ColorIt(14, 4)
CALL LocateIt(16, text$)
text$ = "John De Palma on CompuServe 76076,571"
CALL ColorIt(15, 4)
CALL LocateIt(18, text$)
BEEP
Pause (5)
CALL ColorIt(7, 0)
END IF
SUB ColorIt (Fgd%, Bkgd%)
COLOR Fgd%, Bkgd%
END SUB
SUB CursorOff
LOCATE , , 0
END SUB
SUB CursorOn
LOCATE , , 1, 4, 7
END SUB
'not used, but left it in as it is hard to find this function
FUNCTION IntPeek% (Address%)
IntPeek% = PEEK(Address%) + PEEK((Address% + 1) * 256)
END FUNCTION
SUB IntPoke (Address%, Value%)
'not used, left it in, hard to find pokes an integer.
'the next two statements poke an integer
POKE Address%, Value% AND 255
POKE Address% + 1, Value% \ 256
END SUB
SUB LocateIt (Row%, text$)
LOCATE Row%, FNCenterit(text$)
PRINT text$;
END SUB
SUB Mono (Flag%)
IF PEEK(&H463) = &H4B THEN
'we got a monochrome screen
Flag% = True
ELSE
'we gots color
Flag% = False
END IF
END SUB
SUB Pause (Seconds%)
Start! = TIMER
EndTime! = Start! + Seconds%
DO
Kee$ = INKEY$
LOOP UNTIL TIMER > EndTime! OR LEN(Kee$)
END SUB
SUB PokeColor (Address%, Colr%)
'POKE Address%, Character%
POKE Address% + 1, Colr%
END SUB
FUNCTION ReturnKey$
WHILE INKEY$ <> "": WEND
DO
Kee$ = INKEY$
LOOP UNTIL LEN(Kee$)
ReturnKey$ = Kee$
END FUNCTION
SUB Shadowbox (top%, Bottom%, Wide%, BoxColr%, Fgd%, Bkgd%)
REDIM box$(3)
box$(1) = "█"
box$(2) = "▀"
box$(3) = "▄"
'this sets the colors
COLOR Fgd%, Bkgd%
Left% = (80 - Wide%) \ 2
right% = Left% + Wide%
middle% = right% - Left%
rows% = top%
boxtop% = Wide% - 1
'this prints the box and sets the background color of the box
'if you use a zero, you get a transparent box
IF BoxColr% = 0 THEN GOTO MakeBox
COLOR , BoxColr%
FOR boxsize% = top% TO Bottom%
LOCATE rows%, Left%, 0
PRINT SPACE$(middle%);
rows% = rows% + 1
NEXT
'this prints the box outline
MakeBox:
LOCATE top%, Left%
COLOR Fgd%, Bkgd%
PRINT box$(1); STRING$(boxtop%, box$(2)); box$(1);
FOR rows% = top% + 1 TO Bottom% - 1
LOCATE rows%, Left%
PRINT box$(1);
LOCATE rows%, right%
PRINT box$(1);
NEXT rows%
LOCATE Bottom%, Left%
PRINT box$(1); STRING$(boxtop%, box$(3)); box$(1);
'STOP
'Now the shadow
foregd = 7
Backgd = 0
'use the simple color formula
Colr% = foregd + (16 * Backgd)
'prints the bottom
FOR i = 0 TO Wide%
'from QuickBASIC Bible, p 715
offset% = (Bottom%) * 160 + (Left% + i) * 2
Character% = PEEK(offset%)
CALL PokeColor(offset%, Colr%)
NEXT i
'STOP
'prints the right side
FOR i = top% TO Bottom%
offset% = (i) * 160 + (right%) * 2
Character% = PEEK(offset%)
CALL PokeColor(offset%, Colr%)
offset% = (i) * 160 + (right% + 1) * 2
Character% = PEEK(offset%)
CALL PokeColor(offset%, Colr%)
NEXT
'STOP
END SUB
SUB WaitKey
WHILE INKEY$ <> "": WEND
DO
Kee$ = INKEY$
LOOP UNTIL LEN(Kee$)
IF Kee$ = CHR$(27) THEN END
END SUB